<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="150px">
      <el-form-item label="用户名" prop="userName">
        <el-input v-model="form.userName" readonly/>
      </el-form-item>
      <el-form-item label="用户手机号" prop="userPhone">
        <el-input v-model="form.userPhone" readonly/>
      </el-form-item>
      <el-form-item label="上级用户名称" prop="superiorUserName">
        <el-input v-model="form.superiorUserName" readonly/>
      </el-form-item>
      <el-form-item label="是否实名认证" prop="autonymType">
        <el-input v-model="form.autonymType" readonly/>
      </el-form-item>
      <el-form-item label="身份证号" prop="identityMark">
        <el-input v-model="form.identityMark" readonly/>
      </el-form-item>
      <el-form-item label="银行卡号" prop="bankCardMark">
        <el-input v-model="form.bankCardMark" readonly/>
      </el-form-item>
      <el-form-item label="银行名称" prop="bankName">
        <el-input v-model="form.bankName" readonly/>
      </el-form-item>
      <el-form-item label="支行名称" prop="subBranch">
        <el-input v-model="form.subBranch" readonly/>
      </el-form-item>
      <el-form-item label="身份证照片正面" prop="identityZhengImg">
        <img :src="form.identityZhengImg" width="10%" height="10%"/>
      </el-form-item>
      <el-form-item label="身份证照片反面" prop="identityFanImg">
        <img :src="form.identityFanImg" width="10%" height="10%"/>
      </el-form-item>
      <el-form-item label="银行卡号正面" prop="bankCardZhengImg">
        <img :src="form.bankCardZhengImg" width="10%" height="10%"/>
      </el-form-item>
      <el-form-item label="实名认证时间" prop="autonymTime">
        <el-input v-model="form.autonymTime" readonly/>
      </el-form-item>
      <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
        <el-button @click="close()">返回</el-button>
      </el-form-item>
      <!--<el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>-->
    </el-form>
  </div>
</template>

<script>
import { listTUserInfo, getTUserInfo, delTUserInfo, addTUserInfo, updateTUserInfo, exportTUserInfo } from "@/api/pos/TUserInfo";

export default {
  name: "userCFheckDetail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户基础数据表格数据
      TUserInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: null,
        userPhone: null,
        gradeCode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    const userId = this.$route.query && this.$route.query.userId;
    //console.log(this.$route.query , "----", this.$route.query.userId);
    if (userId) {
      getTUserInfo(userId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户基础数据";
      });
    }
    //this.getList();
  },
  methods: {
    /** 关闭按钮 */
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({path: "/userManage/TUserInfo/check", query: {t: Date.now(), pageNum: this.$route.query.pageNum}})
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.userId != null) {
            updateTUserInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTUserInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有用户基础数据数据项？').then(() => {
        this.exportLoading = true;
        return exportTUserInfo(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>
